SingleChildScrollView

  • Usage

    The SingleChildScrollView widget is a powerful tool that allows you to make any part of your UI scrollable.

    When to Use

    You should consider using the SingleChildScrollView widget when you have a portion of your UI that might overflow the screen, and you want to ensure that users can scroll through it.

    Code

    
    
    import 'package:flutter/material.dart';
    
    void main() {
      runApp(MyApp());
    }
    
    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          home: Scaffold(
            appBar: AppBar(
              title: Text('SingleChildScrollView Example'),
            ),
            body: SingleChildScrollView(
              child: Column(
                children: <Widget>[
                  Container(
                    height: 200.0,
                    color: Colors.blue,
                    child: Center(
                      child: Text(
                        'Header Content',
                        style: TextStyle(
                          color: Colors.white,
                          fontSize: 24.0,
                        ),
                      ),
                    ),
                  ),
                  Container(
                    height: 1000.0, // This container's height exceeds the screen height.
                    color: Colors.green,
                    child: Center(
                      child: Text(
                        'Scrollable Content',
                        style: TextStyle(
                          color: Colors.white,
                          fontSize: 24.0,
                        ),
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ),
        );
      }
    }